from base.base import Base
from selenium.webdriver.common.by import By
from time import sleep


class Hou_UI(Base):
    name = (By.NAME, 'username')
    pwd = (By.NAME, 'password')
    dl_btn = (By.XPATH, '/html/body/div/div/form/div[3]/div/button')

    def login(self):
        self.send_keys(*self.name, text='admin')
        self.send_keys(*self.pwd, text='111111')
        self.click(*self.dl_btn)

    sixin_list = (By.XPATH, '/html/body/div/div/div[1]/div[1]/div/ul/div[9]/a/li')
    huifu = (By.XPATH, '/html/body/div/div/div[2]/section/div/div[1]/div[3]/table/tbody/tr[1]/td[9]/div/button[1]/span')
    neirong = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[2]/div/div[2]/form/div[3]/div/div/div/textarea')
    queding = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[2]/div/div[3]/div/button[2]/span')

    def hui_sixin(self):
        self.click(*self.sixin_list)
        self.click(*self.huifu)
        self.click(*self.neirong)
        self.send_keys(*self.neirong, text='同学你好')
        self.click(*self.queding)

    chakan = (By.XPATH, '/html/body/div/div/div[2]/section/div/div[1]/div[3]/table/tbody/tr[1]/td[9]/div/button[2]/span')

    def list_sixin(self):
        self.click(*self.sixin_list)
        self.click(*self.chakan)

    shanchu = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[3]/div/div[2]/div/div[3]/table/tbody/tr[2]/td[9]/div/button[2]/span')
    qued = (By.XPATH, '/html/body/div[2]/div/div[3]/button[2]/span')

    def shan_sixin(self):
        self.click(*self.sixin_list)
        self.click(*self.chakan)
        self.click(*self.shanchu)
        self.click(*self.qued)

    guanbi = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[3]/div/div[1]/button/i')

    def guan_sixin(self):
        self.click(*self.sixin_list)
        self.click(*self.chakan)
        self.click(*self.guanbi)

    kecheng = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/form/div[2]/div/div/div[1]/input')
    # kc = (By.XPATH, '/html/body/div[2]/div[1]/div[1]/ul/li[6]/span') # 虚拟机
    kc = (By.XPATH, '/html/body/div[2]/div[1]/div[1]/ul/li[7]/span')
    # kc = (By.XPATH, '//span[text()="虚拟机"]')  # 虚拟机
    chaxun = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/form/button[1]/span')

    def cha_sixin(self):
        self.click(*self.sixin_list)
        sleep(1)
        self.click(*self.kecheng)
        sleep(1)
        self.click(*self.kc)
        # xnj = self.driver.find_element(*self.kc)
        # print(xnj)
        # xnj.click()
        # print("aaaaaaaaaaaaa", xnj.text,"bbbbbbbbbbbbb")
        sleep(1)
        self.click(*self.chaxun)

    qingkong_btn = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/form/button[2]/span')

    def qingkong(self):
        self.click(*self.sixin_list)
        self.click(*self.kecheng)
        self.click(*self.kc)
        sleep(1)
        self.click(*self.qingkong_btn)

    dingdan = (By.XPATH, '/html/body/div[1]/div/div[1]/div[1]/div/ul/div[8]/a/li')
    yeshu = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[2]/span[1]/div/div')
    five = (By.XPATH, '/html/body/div[2]/div[1]/div[1]/ul/li[1]/span')

    def set_page(self):
        self.click(*self.dingdan)
        self.click(*self.yeshu)
        self.click(*self.five)